/*
 * Created by JFormDesigner on Wed May 07 00:41:21 CST 2025
 */

package com.soft.bams.client;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author 23838
 */
public class MainPanel extends JPanel {
    private ATMClient atm;
    public MainPanel(ATMClient atm) {
        initComponents();
    }
    //注册按钮
    private void register(ActionEvent e) {
        // TODO add your code here
        //获取当前MainPanel的父窗口（ATClient JFrame）->获取它的布局方式->跳转
        CardLayout cardLayout=(CardLayout)this.getParent().getLayout();
        //跳转登录界面
        cardLayout.show(this.getParent(),"registerPanel");
    }
    //登录按钮
    private void login(ActionEvent e) {
        //获取当前MainPanel的父窗口（ATClient JFrame）->获取它的布局方式->跳转
        CardLayout cardLayout=(CardLayout)this.getParent().getLayout();
        //跳转至注册界面
        cardLayout.show(this.getParent(),"loginPanel");
        // TODO add your code here
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        titleLabel = new JLabel();
        registerButton = new JButton();
        loginButton = new JButton();

        //======== this ========
        setLayout(null);

        //---- titleLabel ----
        titleLabel.setText("\u6a21\u62dfICBC ATM\u7ec8\u7aef");
        titleLabel.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
        add(titleLabel);
        titleLabel.setBounds(new Rectangle(new Point(155, 50), titleLabel.getPreferredSize()));

        //---- registerButton ----
        registerButton.setText("\u6ce8 \u518c");
        registerButton.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
        registerButton.addActionListener(e -> register(e));
        add(registerButton);
        registerButton.setBounds(75, 270, 120, 45);

        //---- loginButton ----
        loginButton.setText("\u767b \u5f55");
        loginButton.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
        loginButton.addActionListener(e -> login(e));
        add(loginButton);
        loginButton.setBounds(320, 270, 120, 45);

        setPreferredSize(new Dimension(500, 600));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel titleLabel;
    private JButton registerButton;
    private JButton loginButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
